package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 *  dao通用接口
 */
public interface BrandMapper extends BaseMapper<Brand> {
    /**
     * 批量插入分类与品牌中间表
     * @param brandId   品牌id
     * @param cids      分类集合
     * @return          返回执行条数
     */
    int insertBrandCategory(
            @Param("bid")Long brandId,
            @Param("cids") List<Long> cids);

    @Select("SELECT b.id, b.name, b.letter, b.image " +
            "FROM tb_category_brand cb " +
            "INNER JOIN tb_brand b ON b.id = cb.brand_id" +
            " WHERE cb.category_id = #{cid}")
    List<Brand> queryByCategoryId(@Param("cid") Long cid);
}
